package com.combetter.changxing.ui.dialog;

import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import com.jakewharton.rxbinding2.view.RxView;
import com.combetter.changxing.R;
import com.combetter.changxing.databinding.DialogAgeLimitBinding;
import com.combetter.changxing.util.ResUtils;

/**
 * 年龄限制
 * <p>
 * Created by 深圳唐龙飞讯科技有限公司 on 2018/6/19.
 */
public class AgeLimitDialog extends DialogFragment {
    private DialogAgeLimitBinding mBinding;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        mBinding = DataBindingUtil.inflate(inflater, R.layout.dialog_age_limit, container, false);
        getDialog().setCanceledOnTouchOutside(false); // 外部点击取消
        initVies();
        return mBinding.getRoot();
    }

    @Override
    public void onResume() {
        super.onResume();
        int width = ResUtils.getDimens(getContext(), R.dimen.DIMEN_500PX);
        int height = ResUtils.getDimens(getContext(), R.dimen.DIMEN_300PX);
        getDialog().getWindow().setLayout(width, height);
    }

    private void initVies() {
        RxView.clicks(mBinding.tvScan).subscribe(o -> {
            dismiss();
        });
    }


}
